package plus.logic;

import com.alibaba.druid.support.json.JSONUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import common.core.util.CustomizeRuntimeException;
import lombok.extern.slf4j.Slf4j;
import plus.util.Condition;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

@Slf4j
public class LogicBaseFeignFallback<T> implements  LogicBaseFeign<T>{

    @Override
    public boolean save(T entity) {
        log.info("触发熔断->save->entity:{}",entity);
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public boolean saveBatch(Condition condition) {
        log.info("触发熔断->saveBatch->condition:{}",JSONUtils.toJSONString(condition));
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public boolean saveOrUpdateBatch(Condition condition) {
        log.info("触发熔断->saveOrUpdateBatch->condition:{}",JSONUtils.toJSONString(condition));
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public boolean removeById(Serializable id) {
        log.info("触发熔断->removeById->id:{}",id);
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public boolean removeByMap(Condition condition) {
        log.info("触发熔断->deleteById->columnMap:{}",JSONUtils.toJSONString(condition));
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public boolean removeByEntity(T entity) {
        log.info("触发熔断->deleteById->columnMap:{}",JSONUtils.toJSONString(entity));
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public boolean removeByIds(Condition condition) {
        log.info("触发熔断->removeByIds->condition:{}",JSONUtils.toJSONString(condition));
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public boolean updateById(T entity) {
        log.info("触发熔断->updateById->entity:{}",entity);
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public boolean updateBatchById(Condition condition) {
        log.info("触发熔断->updateBatchById->condition:{}",JSONUtils.toJSONString(condition));
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public boolean saveOrUpdate(T entity) {
        log.info("触发熔断->saveOrUpdate->entity:{}",entity);
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public T getOneByMap(Condition condition) {
        log.info("触发熔断->getByMap->columnMap:{}",JSONUtils.toJSONString(condition));
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public T getById(Serializable id) {
        log.info("触发熔断->getById->id:{}",id);
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public Collection<T> listByIds(Condition condition) {
        log.info("触发熔断->listByIds->condition:{}",JSONUtils.toJSONString(condition));
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public Collection<T> listByMap(Condition condition) {
        log.info("触发熔断->listByMap->columnMap:{}", JSONUtils.toJSONString(condition));
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public int count() {
        log.info("触发熔断->count");
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public List<T> list() {
        log.info("触发熔断->list");
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public List<Map<String, Object>> listMaps() {
        log.info("触发熔断->listMaps");
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public List<Object> listObjs() {
        log.info("触发熔断->listObjs");
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }

    @Override
    public IPage<T> page(Condition condition) {
        log.info("触发熔断->page");
        throw CustomizeRuntimeException.exception("服务器繁忙,请稍后重试....");
    }
}
